package com.caregiver.watch.business.user.model.vo;

import com.caregiver.watch.business.user.model.po.UserAddress;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @Description: 收货地址
 * @Author 疆戟
 * @Date 2025/8/23 11:20
 * @Version 1.0
 */
@Data
@Schema(title = "收货地址")
public class DeliveryAddressVo {

    @Schema(description = "收货地址ID")
    private Long id;

    @Schema(description = "收货人")
    private String consignee;

    @Schema(description = "收货人手机号")
    private String phone;

    @Schema(description = "省")
    private String province;

    @Schema(description = "市")
    private String city;

    @Schema(description = "区")
    private String district;

    @Schema(description = "详细地址")
    private String detailAddress;

    @Schema(description = "是否默认地址")
    private Boolean isDefault;


    public static DeliveryAddressVo build(UserAddress userAddress) {
        DeliveryAddressVo deliveryAddressVo = new DeliveryAddressVo();
        deliveryAddressVo.id = userAddress.getId();
        deliveryAddressVo.consignee = userAddress.getConsignee();
        deliveryAddressVo.phone = userAddress.getPhone();
        deliveryAddressVo.province = userAddress.getProvince();
        deliveryAddressVo.city = userAddress.getCity();
        deliveryAddressVo.district = userAddress.getDistrict();
        deliveryAddressVo.detailAddress = userAddress.getDetailAddress();
        deliveryAddressVo.isDefault = userAddress.getIsDefault() == 1;
        return deliveryAddressVo;
    }
}
